package com.oa.item.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.spring.annotation.MapperScan;

import com.oa.item.entity.Plan;

@MapperScan
public interface PlanMapper {
    @Delete({
        "delete from plan",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into plan (id, star_time, ",
        "end_time, plan_name, ",
        "creater, creat_time, ",
        "updater, update_time, ",
        "spar, plan_content)",
        "values (#{id,jdbcType=INTEGER}, #{starTime,jdbcType=TIMESTAMP}, ",
        "#{endTime,jdbcType=TIMESTAMP}, #{planName,jdbcType=VARCHAR}, ",
        "#{creater,jdbcType=VARCHAR}, #{creatTime,jdbcType=TIMESTAMP}, ",
        "#{updater,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, ",
        "#{spar,jdbcType=VARCHAR}, #{planContent,jdbcType=LONGVARCHAR})"
    })
    int insert(Plan record);

    @InsertProvider(type=PlanSqlProvider.class, method="insertSelective")
    int insertSelective(Plan record);

    @Select({
        "select",
        "id, star_time, end_time, plan_name, creater, creat_time, updater, update_time, ",
        "spar, plan_content",
        "from plan",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="star_time", property="starTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="end_time", property="endTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="plan_name", property="planName", jdbcType=JdbcType.VARCHAR),
        @Result(column="creater", property="creater", jdbcType=JdbcType.VARCHAR),
        @Result(column="creat_time", property="creatTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updater", property="updater", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="spar", property="spar", jdbcType=JdbcType.VARCHAR),
        @Result(column="plan_content", property="planContent", jdbcType=JdbcType.LONGVARCHAR)
    })
    Plan selectByPrimaryKey(Integer id);
    
    @Select({
        "select",
        "id, star_time, end_time, plan_name, creater, creat_time, updater, update_time, ",
        "spar, plan_content",
        "from plan",
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="star_time", property="starTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="end_time", property="endTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="plan_name", property="planName", jdbcType=JdbcType.VARCHAR),
        @Result(column="creater", property="creater", jdbcType=JdbcType.VARCHAR),
        @Result(column="creat_time", property="creatTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updater", property="updater", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="spar", property="spar", jdbcType=JdbcType.VARCHAR),
        @Result(column="plan_content", property="planContent", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Plan> selectAllPlan();
    
    @Select({
        "select",
        "id, star_time, end_time, plan_name, creater, creat_time, updater, update_time, ",
        "spar, plan_content",
        "from plan",
        "where plan_name = #{planName,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="star_time", property="starTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="end_time", property="endTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="plan_name", property="planName", jdbcType=JdbcType.VARCHAR),
        @Result(column="creater", property="creater", jdbcType=JdbcType.VARCHAR),
        @Result(column="creat_time", property="creatTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="updater", property="updater", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="spar", property="spar", jdbcType=JdbcType.VARCHAR),
        @Result(column="plan_content", property="planContent", jdbcType=JdbcType.LONGVARCHAR)
    })
    Plan selectByPlanName(String planName);

    @UpdateProvider(type=PlanSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Plan record);

    @Update({
        "update plan",
        "set star_time = #{starTime,jdbcType=TIMESTAMP},",
          "end_time = #{endTime,jdbcType=TIMESTAMP},",
          "plan_name = #{planName,jdbcType=VARCHAR},",
          "creater = #{creater,jdbcType=VARCHAR},",
          "creat_time = #{creatTime,jdbcType=TIMESTAMP},",
          "updater = #{updater,jdbcType=VARCHAR},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "spar = #{spar,jdbcType=VARCHAR},",
          "plan_content = #{planContent,jdbcType=LONGVARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(Plan record);

    @Update({
        "update plan",
        "set star_time = #{starTime,jdbcType=TIMESTAMP},",
          "end_time = #{endTime,jdbcType=TIMESTAMP},",
          "plan_name = #{planName,jdbcType=VARCHAR},",
          "creater = #{creater,jdbcType=VARCHAR},",
          "creat_time = #{creatTime,jdbcType=TIMESTAMP},",
          "updater = #{updater,jdbcType=VARCHAR},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "spar = #{spar,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Plan record);
}